<?php
/**
 * Description of Sites
 *
 * @author FFOZEU
 */
namespace Library;

if( !defined('IN') ) die('Hacking Attempt');

class Site extends ApplicationComponent{
    //put your code here
    protected $managers = null;
    
    public function __construct(Application $app){
        parent::__construct($app);
        $this->managers = new Managers('PDO', DbFactory::getPdoInstance());
    }
    
    public function getSiteName(){
        return isset($_SESSION['site'])?$_SESSION['site']['name']:__SITE__;
    }
    
    public function getEmailSerClient(){
        return isset($_SESSION['site'])?$_SESSION['site']['emailServClient']:__EMAIL__;
    }
    
    public function getEmailSerTech(){
        return isset($_SESSION['site'])?$_SESSION['site']['emailServTech']:__EMAIL__;
    }
    
    public function getEmailSerReclamat(){
        return isset($_SESSION['site'])?$_SESSION['site']['emailServReclamation']:__EMAIL__;
    }
    
    public function getEmailPaypal(){
        return isset($_SESSION['site'])?$_SESSION['site']['emailPaypal']:__EMAIL__;
    }
    
    public function getHourOpen(){
        return isset($_SESSION['site'])?$_SESSION['site']['heureOuverture']:  date('H:i');
    }
    
    public function getHourClose(){
        return isset($_SESSION['site'])?$_SESSION['site']['heureFermeture']:date('H:i');
    }
    
    public function getDevise(){
        return isset($_SESSION['site'])?$_SESSION['site']['devise']:_DEFAULT_DEVISE_;
    }
    
    public function getIsoDevise(){
        return isset($_SESSION['site'])?$_SESSION['site']['isoDevise']:_DEFAULT_ISODEVISE_;
    }
    public function setSiteInfos(){
		$manager = $this->managers->getManagerOf('Sites');
		$sites = $manager->getSitesInfos();
		if($sites){
			$_SESSION['site']['nameSites'] = $sites->getNameSites();
			$_SESSION['site']['heureOuverture'] = $sites->getHeureOuverture();
			$_SESSION['site']['heureFermeture'] = $sites->getHeureFermeture();
			$_SESSION['site']['emailServClient'] = $sites->getEmailServClient();
			$_SESSION['site']['emailServTech'] = $sites->getEmailServTech();
			$_SESSION['site']['emailServReclamation'] = $sites->getEmailServReclamation();
			$_SESSION['site']['emailPaypal'] = $sites->getEmailPaypal();
            $_SESSION['site']['devise'] = $sites->getDevise();
            $_SESSION['site']['isoDevise'] = $sites->getIsoDevise();
		}
    }
}

?>
